#include <iostream>
#include <cstring>
using namespace std;

void get_next(int length, char a[], int *next)
{
    int i = 1;
    next[0] = 0;
    int j = 0;
    while (i < length)
    {
        if (j == 0 || a[i-1] == a[j-1])
        {
            ++i;
            ++j;
            next[i] = j;
        }
        else
        {
            j = next[j];
        }
    }
}


int main()
{
    char a[101];
    int x[100]={0};
    cin>>a;
    int l;
    l=strlen(a)+1;
    get_next(l,a,x);
    for(int i=1;i<l;i++)
    {
        cout<<x[i]<<" ";
    }
    return 0;
}